package cn.lili.controller.promotion;

import cn.lili.common.utils.ResultUtil;
import cn.lili.common.vo.PageVO;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.promotion.entity.dos.GreenCount;
import cn.lili.modules.promotion.entity.dos.GreenUnitPrice;
import cn.lili.modules.promotion.entity.vos.GreenContributionInfoVO;
import cn.lili.modules.promotion.entity.vos.GreenCountVO;
import cn.lili.modules.promotion.entity.vos.GreenUnitPriceVO;
import cn.lili.modules.promotion.service.GreenCountService;
import cn.lili.modules.promotion.service.GreenUnitPriceService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pojos.GOrder;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author xiangqian
 * @version 1.0
 * @data 2023/12/18 14:32
 * <p>
 * 绿色积分池-统计
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/promotion/green/count")
public class GreenCountController {

    private final GreenCountService greenCountService;
    private final GreenUnitPriceService greenUnitPriceService;

    /**
     * 查询绿色积分统计数据
     *
     * @return 返回统计结果
     */
    @GetMapping("/getGreenCount")
    public ResultMessage<GreenCountVO> getGreenCount() {
        return ResultUtil.data(greenCountService.getGreenCount());
    }

    /**
     * 查询贡献值统计数据
     *
     * @return 返回统计结果
     */
    @GetMapping("/getContributionCount")
    public ResultMessage<GreenContributionInfoVO> getContributionCount() {
        return ResultUtil.data(greenCountService.getContributionCount());
    }

    /**
     * 分页查询贡献值列表
     *
     * @param greenCount 查询条件{@link GreenCount}
     * @param page       分页条件{@link PageVO}
     * @return 分页返回结果
     */
    @GetMapping("/contributionPage")
    public ResultMessage<Page<GreenCount>> contributionPage(GreenCount greenCount, PageVO page) {
        return ResultUtil.data(greenCountService.contributionPage(greenCount, page));
    }

    /**
     * 分页查询单价列表
     *
     * @param greenUnitPrice 查询条件{@link GreenUnitPrice}
     * @param page           分页条件{@link PageVO}
     * @return 分页返回结果
     */
    @ApiModelProperty("分页查询单价列表")
    @GetMapping("/greenUnitPricePage")
    public ResultMessage<Page<GreenUnitPrice>> greenUnitPricePage(GreenUnitPrice greenUnitPrice, PageVO page) {
        return ResultUtil.data(greenUnitPriceService.greenUnitPricePage(greenUnitPrice, page));
    }

    /**
     * 查询单价折线图
     *
     * @param type 查询条件 0：按日查询，1，按周查询，2，按本月查询
     * @return 分页返回结果
     */
    @GetMapping("/greenUnitPricePicturePage")
    public ResultMessage<List<GreenUnitPriceVO>> greenUnitPricePicturePage(String type) {
        return ResultUtil.data(greenUnitPriceService.greenUnitPricePicturePage(type));
    }


    /**
     * 运营中心-绿色积分明细 已废弃
     */
    @GetMapping("/getGreenDetailPage")
    @ApiOperation("运营中心-绿色积分明细-废弃")
    public ResultMessage<Page<GOrder>> getGreenDetailPage(PageVO page) {
        return ResultUtil.data(greenCountService.getGreenDetailPage(page));
    }
}
